<template>
    <div>
      用户名：<input type="text" v-model="username">
      密码：<input type="password" v-model="password">
      <button @click="deng">登录</button>
    </div>
</template>

<script>
    export default {
        name: "login",
      data(){
          return{
            username:'',
            password:''
          }
      },
      methods:{
          deng(){
            this.axios({
              url:'http://127.0.0.1:8000/mdlogin/',
              method:'post',
              data:{
                username:this.username,
                password:this.password
              }
            }).then(res=>{
              if (res.data.code==200){
                localStorage.setItem('uid',res.data.data);
                alert('登录成功');
                this.$router.push({'name':'allgoodsinfo'})

              }
            })
          }
      }
    }
</script>

<style scoped>

</style>
